﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AigisEXPCalculator
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        int[,] map = new int[7, 111];
        int[,] sum = new int[7, 111];
        public MainWindow()
        {
            InitializeComponent();
            map[1, 1] = 32;
            map[2, 1] = 35;
            map[3, 1] = 38;
            map[4, 1] = 42;
            map[5, 1] = 45;
            map[6, 1] = 48;
            map[1, 2] = 33;
            map[2, 2] = 37;
            map[3, 2] = 40;
            map[4, 2] = 43;
            map[5, 2] = 46;
            map[6, 2] = 50;
            map[1, 3] = 35;
            map[2, 3] = 38;
            map[3, 3] = 42;
            map[4, 3] = 45;
            map[5, 3] = 49;
            map[6, 3] = 52;
            map[1, 4] = 35;
            map[2, 4] = 39;
            map[3, 4] = 42;
            map[4, 4] = 46;
            map[5, 4] = 49;
            map[6, 4] = 53;
            map[1, 5] = 37;
            map[2, 5] = 40;
            map[3, 5] = 44;
            map[4, 5] = 48;
            map[5, 5] = 52;
            map[6, 5] = 55;
            map[1, 6] = 39;
            map[2, 6] = 43;
            map[3, 6] = 47;
            map[4, 6] = 50;
            map[5, 6] = 54;
            map[6, 6] = 59;
            map[1, 7] = 39;
            map[2, 7] = 43;
            map[3, 7] = 47;
            map[4, 7] = 51;
            map[5, 7] = 55;
            map[6, 7] = 58;
            map[1, 8] = 41;
            map[2, 8] = 45;
            map[3, 8] = 49;
            map[4, 8] = 53;
            map[5, 8] = 57;
            map[6, 8] = 62;
            map[1, 9] = 42;
            map[2, 9] = 46;
            map[3, 9] = 51;
            map[4, 9] = 55;
            map[5, 9] = 59;
            map[6, 9] = 63;
            map[1, 10] = 85;
            map[2, 10] = 94;
            map[3, 10] = 102;
            map[4, 10] = 110;
            map[5, 10] = 119;
            map[6, 10] = 127;
            map[1, 11] = 88;
            map[2, 11] = 97;
            map[3, 11] = 105;
            map[4, 11] = 115;
            map[5, 11] = 123;
            map[6, 11] = 132;
            map[1, 12] = 92;
            map[2, 12] = 101;
            map[3, 12] = 111;
            map[4, 12] = 119;
            map[5, 12] = 129;
            map[6, 12] = 138;
            map[1, 13] = 95;
            map[2, 13] = 104;
            map[3, 13] = 114;
            map[4, 13] = 124;
            map[5, 13] = 133;
            map[6, 13] = 143;
            map[1, 14] = 98;
            map[2, 14] = 108;
            map[3, 14] = 117;
            map[4, 14] = 127;
            map[5, 14] = 137;
            map[6, 14] = 147;
            map[1, 15] = 102;
            map[2, 15] = 112;
            map[3, 15] = 123;
            map[4, 15] = 133;
            map[5, 15] = 143;
            map[6, 15] = 153;
            map[1, 16] = 105;
            map[2, 16] = 116;
            map[3, 16] = 126;
            map[4, 16] = 136;
            map[5, 16] = 147;
            map[6, 16] = 157;
            map[1, 17] = 108;
            map[2, 17] = 119;
            map[3, 17] = 129;
            map[4, 17] = 141;
            map[5, 17] = 151;
            map[6, 17] = 162;
            map[1, 18] = 112;
            map[2, 18] = 123;
            map[3, 18] = 135;
            map[4, 18] = 145;
            map[5, 18] = 157;
            map[6, 18] = 168;
            map[1, 19] = 115;
            map[2, 19] = 126;
            map[3, 19] = 138;
            map[4, 19] = 150;
            map[5, 19] = 161;
            map[6, 19] = 173;
            map[1, 20] = 170;
            map[2, 20] = 187;
            map[3, 20] = 204;
            map[4, 20] = 221;
            map[5, 20] = 238;
            map[6, 20] = 255;
            map[1, 21] = 176;
            map[2, 21] = 194;
            map[3, 21] = 211;
            map[4, 21] = 229;
            map[5, 21] = 247;
            map[6, 21] = 264;
            map[1, 22] = 183;
            map[2, 22] = 201;
            map[3, 22] = 219;
            map[4, 22] = 238;
            map[5, 22] = 256;
            map[6, 22] = 274;
            map[1, 23] = 190;
            map[2, 23] = 209;
            map[3, 23] = 228;
            map[4, 23] = 247;
            map[5, 23] = 266;
            map[6, 23] = 285;
            map[1, 24] = 197;
            map[2, 24] = 217;
            map[3, 24] = 237;
            map[4, 24] = 256;
            map[5, 24] = 276;
            map[6, 24] = 296;
            map[1, 25] = 203;
            map[2, 25] = 223;
            map[3, 25] = 243;
            map[4, 25] = 264;
            map[5, 25] = 284;
            map[6, 25] = 304;
            map[1, 26] = 210;
            map[2, 26] = 231;
            map[3, 26] = 252;
            map[4, 26] = 273;
            map[5, 26] = 294;
            map[6, 26] = 315;
            map[1, 27] = 217;
            map[2, 27] = 239;
            map[3, 27] = 261;
            map[4, 27] = 282;
            map[5, 27] = 304;
            map[6, 27] = 326;
            map[1, 28] = 224;
            map[2, 28] = 246;
            map[3, 28] = 269;
            map[4, 28] = 291;
            map[5, 28] = 313;
            map[6, 28] = 336;
            map[1, 29] = 230;
            map[2, 29] = 253;
            map[3, 29] = 276;
            map[4, 29] = 299;
            map[5, 29] = 322;
            map[6, 29] = 345;
            map[1, 30] = 0;
            map[2, 30] = 312;
            map[3, 30] = 339;
            map[4, 30] = 368;
            map[5, 30] = 396;
            map[6, 30] = 424;
            map[1, 31] = 0;
            map[2, 31] = 323;
            map[3, 31] = 353;
            map[4, 31] = 382;
            map[5, 31] = 412;
            map[6, 31] = 441;
            map[1, 32] = 0;
            map[2, 32] = 336;
            map[3, 32] = 366;
            map[4, 32] = 397;
            map[5, 32] = 427;
            map[6, 32] = 458;
            map[1, 33] = 0;
            map[2, 33] = 347;
            map[3, 33] = 379;
            map[4, 33] = 410;
            map[5, 33] = 442;
            map[6, 33] = 474;
            map[1, 34] = 0;
            map[2, 34] = 361;
            map[3, 34] = 394;
            map[4, 34] = 427;
            map[5, 34] = 460;
            map[6, 34] = 492;
            map[1, 35] = 0;
            map[2, 35] = 373;
            map[3, 35] = 407;
            map[4, 35] = 440;
            map[5, 35] = 474;
            map[6, 35] = 508;
            map[1, 36] = 0;
            map[2, 36] = 385;
            map[3, 36] = 420;
            map[4, 36] = 455;
            map[5, 36] = 490;
            map[6, 36] = 525;
            map[1, 37] = 0;
            map[2, 37] = 398;
            map[3, 37] = 434;
            map[4, 37] = 471;
            map[5, 37] = 507;
            map[6, 37] = 543;
            map[1, 38] = 0;
            map[2, 38] = 409;
            map[3, 38] = 446;
            map[4, 38] = 484;
            map[5, 38] = 521;
            map[6, 38] = 558;
            map[1, 39] = 0;
            map[2, 39] = 424;
            map[3, 39] = 462;
            map[4, 39] = 500;
            map[5, 39] = 539;
            map[6, 39] = 578;
            map[1, 40] = 0;
            map[2, 40] = 0;
            map[3, 40] = 678;
            map[4, 40] = 735;
            map[5, 40] = 791;
            map[6, 40] = 847;
            map[1, 41] = 0;
            map[2, 41] = 0;
            map[3, 41] = 705;
            map[4, 41] = 763;
            map[5, 41] = 822;
            map[6, 41] = 881;
            map[1, 42] = 0;
            map[2, 42] = 0;
            map[3, 42] = 732;
            map[4, 42] = 793;
            map[5, 42] = 854;
            map[6, 42] = 915;
            map[1, 43] = 0;
            map[2, 43] = 0;
            map[3, 43] = 759;
            map[4, 43] = 823;
            map[5, 43] = 886;
            map[6, 43] = 949;
            map[1, 44] = 0;
            map[2, 44] = 0;
            map[3, 44] = 788;
            map[4, 44] = 852;
            map[5, 44] = 918;
            map[6, 44] = 984;
            map[1, 45] = 0;
            map[2, 45] = 0;
            map[3, 45] = 812;
            map[4, 45] = 881;
            map[5, 45] = 948;
            map[6, 45] = 1016;
            map[1, 46] = 0;
            map[2, 46] = 0;
            map[3, 46] = 841;
            map[4, 46] = 911;
            map[5, 46] = 981;
            map[6, 46] = 1051;
            map[1, 47] = 0;
            map[2, 47] = 0;
            map[3, 47] = 868;
            map[4, 47] = 940;
            map[5, 47] = 1013;
            map[6, 47] = 1085;
            map[1, 48] = 0;
            map[2, 48] = 0;
            map[3, 48] = 895;
            map[4, 48] = 970;
            map[5, 48] = 1044;
            map[6, 48] = 1119;
            map[1, 49] = 0;
            map[2, 49] = 0;
            map[3, 49] = 922;
            map[4, 49] = 998;
            map[5, 49] = 1075;
            map[6, 49] = 1152;
            map[1, 50] = 0;
            map[2, 50] = 0;
            map[3, 50] = 1017;
            map[4, 50] = 1102;
            map[5, 50] = 1187;
            map[6, 50] = 1272;
            map[1, 51] = 0;
            map[2, 51] = 0;
            map[3, 51] = 1057;
            map[4, 51] = 1146;
            map[5, 51] = 1234;
            map[6, 51] = 1321;
            map[1, 52] = 0;
            map[2, 52] = 0;
            map[3, 52] = 1098;
            map[4, 52] = 1189;
            map[5, 52] = 1281;
            map[6, 52] = 1373;
            map[1, 53] = 0;
            map[2, 53] = 0;
            map[3, 53] = 1140;
            map[4, 53] = 1235;
            map[5, 53] = 1330;
            map[6, 53] = 1425;
            map[1, 54] = 0;
            map[2, 54] = 0;
            map[3, 54] = 1180;
            map[4, 54] = 1278;
            map[5, 54] = 1376;
            map[6, 54] = 1474;
            map[1, 55] = 0;
            map[2, 55] = 0;
            map[3, 55] = 0;
            map[4, 55] = 1322;
            map[5, 55] = 1424;
            map[6, 55] = 1526;
            map[1, 56] = 0;
            map[2, 56] = 0;
            map[3, 56] = 0;
            map[4, 56] = 1365;
            map[5, 56] = 1470;
            map[6, 56] = 1575;
            map[1, 57] = 0;
            map[2, 57] = 0;
            map[3, 57] = 0;
            map[4, 57] = 1411;
            map[5, 57] = 1519;
            map[6, 57] = 1627;
            map[1, 58] = 0;
            map[2, 58] = 0;
            map[3, 58] = 0;
            map[4, 58] = 1454;
            map[5, 58] = 1566;
            map[6, 58] = 1679;
            map[1, 59] = 0;
            map[2, 59] = 0;
            map[3, 59] = 0;
            map[4, 59] = 1498;
            map[5, 59] = 1613;
            map[6, 59] = 1728;
            map[1, 60] = 0;
            map[2, 60] = 0;
            map[3, 60] = 0;
            map[4, 60] = 1469;
            map[5, 60] = 1582;
            map[6, 60] = 1695;
            map[1, 61] = 0;
            map[2, 61] = 0;
            map[3, 61] = 0;
            map[4, 61] = 1527;
            map[5, 61] = 1645;
            map[6, 61] = 1762;
            map[1, 62] = 0;
            map[2, 62] = 0;
            map[3, 62] = 0;
            map[4, 62] = 1588;
            map[5, 62] = 1710;
            map[6, 62] = 1832;
            map[1, 63] = 0;
            map[2, 63] = 0;
            map[3, 63] = 0;
            map[4, 63] = 1644;
            map[5, 63] = 1771;
            map[6, 63] = 1897;
            map[1, 64] = 0;
            map[2, 64] = 0;
            map[3, 64] = 0;
            map[4, 64] = 1705;
            map[5, 64] = 1835;
            map[6, 64] = 1967;
            map[1, 65] = 0;
            map[2, 65] = 0;
            map[3, 65] = 0;
            map[4, 65] = 1762;
            map[5, 65] = 1898;
            map[6, 65] = 2034;
            map[1, 66] = 0;
            map[2, 66] = 0;
            map[3, 66] = 0;
            map[4, 66] = 1822;
            map[5, 66] = 1962;
            map[6, 66] = 2101;
            map[1, 67] = 0;
            map[2, 67] = 0;
            map[3, 67] = 0;
            map[4, 67] = 1879;
            map[5, 67] = 2024;
            map[6, 67] = 2169;
            map[1, 68] = 0;
            map[2, 68] = 0;
            map[3, 68] = 0;
            map[4, 68] = 1940;
            map[5, 68] = 2089;
            map[6, 68] = 2238;
            map[1, 69] = 0;
            map[2, 69] = 0;
            map[3, 69] = 0;
            map[4, 69] = 1998;
            map[5, 69] = 2152;
            map[6, 69] = 2306;
            map[1, 70] = 0;
            map[2, 70] = 0;
            map[3, 70] = 0;
            map[4, 70] = 1836;
            map[5, 70] = 1977;
            map[6, 70] = 2118;
            map[1, 71] = 0;
            map[2, 71] = 0;
            map[3, 71] = 0;
            map[4, 71] = 1909;
            map[5, 71] = 2056;
            map[6, 71] = 2203;
            map[1, 72] = 0;
            map[2, 72] = 0;
            map[3, 72] = 0;
            map[4, 72] = 1983;
            map[5, 72] = 2135;
            map[6, 72] = 2288;
            map[1, 73] = 0;
            map[2, 73] = 0;
            map[3, 73] = 0;
            map[4, 73] = 2057;
            map[5, 73] = 2215;
            map[6, 73] = 2373;
            map[1, 74] = 0;
            map[2, 74] = 0;
            map[3, 74] = 0;
            map[4, 74] = 2130;
            map[5, 74] = 2295;
            map[6, 74] = 2458;
            map[1, 75] = 0;
            map[2, 75] = 0;
            map[3, 75] = 0;
            map[4, 75] = 2204;
            map[5, 75] = 2373;
            map[6, 75] = 2543;
            map[1, 76] = 0;
            map[2, 76] = 0;
            map[3, 76] = 0;
            map[4, 76] = 2276;
            map[5, 76] = 2451;
            map[6, 76] = 2626;
            map[1, 77] = 0;
            map[2, 77] = 0;
            map[3, 77] = 0;
            map[4, 77] = 2350;
            map[5, 77] = 2531;
            map[6, 77] = 2712;
            map[1, 78] = 0;
            map[2, 78] = 0;
            map[3, 78] = 0;
            map[4, 78] = 2424;
            map[5, 78] = 2610;
            map[6, 78] = 2796;
            map[1, 79] = 0;
            map[2, 79] = 0;
            map[3, 79] = 0;
            map[4, 79] = 2497;
            map[5, 79] = 2689;
            map[6, 79] = 2882;
            map[1, 80] = 0;
            map[2, 80] = 0;
            map[3, 80] = 0;
            map[4, 80] = 2571;
            map[5, 80] = 2769;
            map[6, 80] = 2967;
            map[1, 81] = 0;
            map[2, 81] = 0;
            map[3, 81] = 0;
            map[4, 81] = 2673;
            map[5, 81] = 2879;
            map[6, 81] = 3084;
            map[1, 82] = 0;
            map[2, 82] = 0;
            map[3, 82] = 0;
            map[4, 82] = 2777;
            map[5, 82] = 2990;
            map[6, 82] = 3204;
            map[1, 83] = 0;
            map[2, 83] = 0;
            map[3, 83] = 0;
            map[4, 83] = 2879;
            map[5, 83] = 3101;
            map[6, 83] = 3322;
            map[1, 84] = 0;
            map[2, 84] = 0;
            map[3, 84] = 0;
            map[4, 84] = 2981;
            map[5, 84] = 3210;
            map[6, 84] = 3440;
            map[1, 85] = 0;
            map[2, 85] = 0;
            map[3, 85] = 0;
            map[4, 85] = 3085;
            map[5, 85] = 3323;
            map[6, 85] = 3559;
            map[1, 86] = 0;
            map[2, 86] = 0;
            map[3, 86] = 0;
            map[4, 86] = 3188;
            map[5, 86] = 3432;
            map[6, 86] = 3678;
            map[1, 87] = 0;
            map[2, 87] = 0;
            map[3, 87] = 0;
            map[4, 87] = 3290;
            map[5, 87] = 3544;
            map[6, 87] = 3797;
            map[1, 88] = 0;
            map[2, 88] = 0;
            map[3, 88] = 0;
            map[4, 88] = 3393;
            map[5, 88] = 3654;
            map[6, 88] = 3915;
            map[1, 89] = 0;
            map[2, 89] = 0;
            map[3, 89] = 0;
            map[4, 89] = 3497;
            map[5, 89] = 3766;
            map[6, 89] = 4035;
            map[1, 90] = 0;
            map[2, 90] = 0;
            map[3, 90] = 0;
            map[4, 90] = 2570;
            map[5, 90] = 2768;
            map[6, 90] = 2965;
            map[1, 91] = 0;
            map[2, 91] = 0;
            map[3, 91] = 0;
            map[4, 91] = 2674;
            map[5, 91] = 2879;
            map[6, 91] = 3086;
            map[1, 92] = 0;
            map[2, 92] = 0;
            map[3, 92] = 0;
            map[4, 92] = 2776;
            map[5, 92] = 2989;
            map[6, 92] = 3202;
            map[1, 93] = 0;
            map[2, 93] = 0;
            map[3, 93] = 0;
            map[4, 93] = 2879;
            map[5, 93] = 3101;
            map[6, 93] = 3323;
            map[1, 94] = 0;
            map[2, 94] = 0;
            map[3, 94] = 0;
            map[4, 94] = 2983;
            map[5, 94] = 3212;
            map[6, 94] = 3441;
            map[1, 95] = 0;
            map[2, 95] = 0;
            map[3, 95] = 0;
            map[4, 95] = 3084;
            map[5, 95] = 3322;
            map[6, 95] = 3559;
            map[1, 96] = 0;
            map[2, 96] = 0;
            map[3, 96] = 0;
            map[4, 96] = 3187;
            map[5, 96] = 3432;
            map[6, 96] = 3677;
            map[1, 97] = 0;
            map[2, 97] = 0;
            map[3, 97] = 0;
            map[4, 97] = 3291;
            map[5, 97] = 3544;
            map[6, 97] = 3798;
            map[1, 98] = 0;
            map[2, 98] = 0;
            map[3, 98] = 0;
            map[4, 98] = 3393;
            map[5, 98] = 3654;
            map[6, 98] = 3915;
            map[1, 99] = 0;
            map[2, 99] = 0;
            map[3, 99] = 0;
            map[4, 99] = 0;
            map[5, 99] = 0;
            map[6, 99] = 0;
            for (int i = 1; i <= 6; i ++)
                for (int j = 1; j <= 100; j++)
                {
                    sum[i, j] = sum[i, j - 1] + map[i, j - 1];
                }
            //calcmain();
        }

        void calcmain()
        {
            try
            {
                int nowlv, nowexp, tolv, toexp, feedexp, rare;
                rare = 6;
                if (rb1.IsChecked == true) rare = 1;
                if (rb2.IsChecked == true) rare = 2;
                if (rb3.IsChecked == true) rare = 3;
                if (rb4.IsChecked == true) rare = 4;
                if (rb5.IsChecked == true) rare = 5;
                if (rb6.IsChecked == true) rare = 6;
                nowlv = Convert.ToInt32(NowLV.Text);
                if (NowEXP.Text.Length != 0) nowexp = Convert.ToInt32(NowEXP.Text);
                else nowexp = map[rare, nowlv];
                tolv = Convert.ToInt32(ToLV.Text);
                if (ToEXP.Text.Length != 0) toexp = Convert.ToInt32(ToEXP.Text);
                else toexp = map[rare, tolv];
                feedexp = Convert.ToInt32(FeedEXP.Text);
                nowexp = sum[rare, nowlv + 1] - nowexp;
                toexp = sum[rare, tolv + 1] - toexp;
                NeedEXP.Text = (toexp - nowexp).ToString();
                NeedFeed.Text = ((toexp - nowexp) / feedexp).ToString();
                RemainEXP.Text = ((toexp - nowexp) % feedexp).ToString();
            }
            catch (Exception ex)
            {
            }
        }

        private void TextChanged(object sender, TextChangedEventArgs e)
        {
            calcmain();
        }

        private void Click(object sender, RoutedEventArgs e)
        {
            calcmain();
        }

    }
}
